<?php /* SVN: $Id: index.ctp 1721 2010-04-17 11:06:44Z preethi_083at09 $ */ ?>


           <div class="l-curve-top">
                            <div class="r-curve-top">
                              <div class="top-bg"></div>
                            </div>
                          </div>
            <div class="shad-bg-lft clearfix">
                <div class="shad-bg-rgt">
                    <div class="shad-bg clearfix">
                    
<h2><?php echo __l('Affiliate Fund Withdrawal Request'); ?></h2>
<div class="userCashWithdrawals index js-response js-withdrawal_responses js-responses">
<?php if(!empty($moneyTransferAccounts)) { ?>
        <?php echo $this->element('../affiliate_cash_withdrawals/add'); ?>
<?php }
else
{ ?>
<div class="content-info">
<b>
<?php
 echo $this->Html->link(__l('Your money transfer account is empty, so click here to update your money transfer account.'), array('controller' => 'money_transfer_accounts', 'action'=>'index'), array('title' => __l('Edit money transfer accounts')));
 ?>
 </b>
 </div>
<?php
}
?>
<?php echo $this->element('paging_counter');?>
<table class="list">
    <tr>
		<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Requested On'), 'AffiliateCashWithdrawal.created');?></div></th>
        <th class="dr"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Requested Amount').' ('.Configure::read('site.currency').')', 'AffiliateCashWithdrawal.amount');?></div></th>
<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Transaction Fee ('.Configure::read('site.currency').')'));?></div></th>
<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Paid Amount (Requested Amount - Transaction Fee) ('.Configure::read('site.currency').')'));?></div></th>
<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Status'),'AffiliateCashWithdrawalStatus.name');?></div></th>
    </tr>
<?php
if (!empty($userCashWithdrawals)):
$i = 0;
foreach ($userCashWithdrawals as $userCashWithdrawal):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td><?php echo $this->Html->cDateTime($userCashWithdrawal['AffiliateCashWithdrawal']['created']);?></td>
    	<td class="dr"><?php echo $userCashWithdrawal['AffiliateCashWithdrawal']['amount'];?></td>
		<td><?php echo  $this->Html->cCurrency($userCashWithdrawal['AffiliateCashWithdrawal']['commission_amount']);?></td>
        <td><?php if($userCashWithdrawal['AffiliateCashWithdrawalStatus']['id'] != ConstAffiliateCashWithdrawalStatus::Rejected or $userCashWithdrawal['AffiliateCashWithdrawalStatus']['id'] != ConstAffiliateCashWithdrawalStatus::Failed)
                    echo $this->Html->cCurrency(($userCashWithdrawal['AffiliateCashWithdrawal']['amount'] - $userCashWithdrawal['AffiliateCashWithdrawal']['commission_amount']));
                   else
                    echo '--';
                    ?></td>
        <td>
		<?php
			if($userCashWithdrawal['AffiliateCashWithdrawalStatus']['id'] == ConstAffiliateCashWithdrawalStatus::Pending):
				echo __l('Pending');
			elseif($userCashWithdrawal['AffiliateCashWithdrawalStatus']['id'] == ConstAffiliateCashWithdrawalStatus::Approved):
				echo __l('Under Process');
			elseif($userCashWithdrawal['AffiliateCashWithdrawalStatus']['id'] == ConstAffiliateCashWithdrawalStatus::Rejected):
				echo __l('Rejected');
			elseif($userCashWithdrawal['AffiliateCashWithdrawalStatus']['id'] == ConstAffiliateCashWithdrawalStatus::Failed):
				echo __l('Failed');
			elseif($userCashWithdrawal['AffiliateCashWithdrawalStatus']['id'] == ConstAffiliateCashWithdrawalStatus::Success):
				 echo __l('Success');
			else:
				echo $this->Html->cText($userCashWithdrawal['AffiliateCashWithdrawalStatus']['name']);
			endif;
		?>
		</td>
	</tr>
<?php
    endforeach;
else:
?>
	<tr>
		<td colspan="8" class="notice"><?php echo __l('No withdraw requests available');?></td>
	</tr>
<?php
endif;
?>
</table>

<?php
if (!empty($userCashWithdrawals)) { ?>
      <div class="js-pagination"> <?php echo $this->element('paging_links'); ?> </div> 
<?php } ?>
</div>

                    </div>
                </div>
            </div>
                    <div class="l-curve-bot">
                            <div class="r-curve-bot">
                              <div class="bot-bg"></div>
                            </div>
                          </div>
